import requests

def download_m3u8_file(url, name):
    resp = requests.get(url)
    with open(f"实验数据/video2/m3u8文件/{name}", mode="wb") as f:
        f.write(resp.content)
    print('m3u8文件下载完成！')


def main(url):
    # 下载m3u8文件
    download_m3u8_file(url, "m3u8.txt")

if __name__ == '__main__':
    # 需要输入m3u8下载地址
    url = "https://vip3.slbfsl.com/20231003/0biU8Y0j/1000kb/hls/index.m3u8"
    # 51专用（这个比较严，需要关代理）
    # url = "https://hls.vdtuzv.com/videos3/6d39278c8aa6c4980923e688df4246d3/6d39278c8aa6c4980923e688df4246d3.m3u8?auth_key=1714821749-66361a753e1e9-0-8d556a8d57674b9f041283d5a2bc521a&v=3&time=0"
    main(url)